package com.tree;

public class BinaryTreeMathPathSum {
    public int maxPathSum(TreeNode root){
        if (root == null) return 0;

        int left = maxPathSum(root.left);
        int right = maxPathSum(root.right);

        return Math.max(0, Math.max(left, right)) + root.val;
    }
}
